﻿<Window x:Class="AdTech.Snap.Overlay"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:sys="clr-namespace:System;assembly=mscorlib"
        xmlns:cmn="http://adtech-dev.com/Common"
        xmlns:interop="clr-namespace:AdTech.Snap.Interop"
        xmlns:local="clr-namespace:AdTech.Snap"
        Title="Snap"
        WindowStyle="None"
        ResizeMode="NoResize"
        AllowsTransparency="True"
        Background="#01000000"
        ShowInTaskbar="False"
        cmn:Common.DialogResult="{Binding DialogResult}">
    <Window.Resources>
        <ObjectDataProvider x:Key="ScreenBounds" MethodName="GetTotalScreenBoundaries" ObjectType="{x:Type interop:MonitorInteropHelper}" />
        <ObjectDataProvider x:Key="RelativeScreenBounds" MethodName="GetTotalScreenBoundaries" ObjectType="{x:Type interop:MonitorInteropHelper}">
            <ObjectDataProvider.MethodParameters>
                <sys:Boolean>True</sys:Boolean>
            </ObjectDataProvider.MethodParameters>
        </ObjectDataProvider>
    </Window.Resources>
    <Window.Style>
        <Style TargetType="{x:Type Window}">
            <Setter Property="Left" Value="{Binding Left, Source={StaticResource ScreenBounds}}" />
            <Setter Property="Top" Value="{Binding Top, Source={StaticResource ScreenBounds}}" />
            <Setter Property="Width" Value="{Binding Width, Source={StaticResource ScreenBounds}}" />
            <Setter Property="Height" Value="{Binding Height, Source={StaticResource ScreenBounds}}" />
            <Style.Triggers>
                <DataTrigger Binding="{Binding Source={x:Static local:Bootstrapper.Debug}}" Value="False">
                    <Setter Property="Topmost" Value="True" />
                </DataTrigger>
                <DataTrigger Binding="{Binding Source={x:Static local:Bootstrapper.Debug}}" Value="True">
                    <Setter Property="Topmost" Value="False" />
                </DataTrigger>
            </Style.Triggers>
        </Style>
    </Window.Style>
    <cmn:AttachedCommandBehaviour.Bindings>
        <cmn:AttachedCommandBinding Command="{Binding LoadedCommand}" Event="Loaded" />
        <cmn:AttachedCommandBinding Command="{Binding UnloadedCommand}" Event="Unloaded" />
        <cmn:AttachedCommandBinding Command="{Binding MouseLeftButtonDownCommand}" Event="MouseLeftButtonDown" />
        <cmn:AttachedCommandBinding Command="{Binding MouseLeftButtonUpCommand}" Event="MouseLeftButtonUp" />
        <cmn:AttachedCommandBinding Command="{Binding MouseMoveCommand}" Event="MouseMove" />
        <cmn:AttachedCommandBinding Command="{Binding KeyDownCommand}" Event="KeyDown" />
        <cmn:AttachedCommandBinding Command="{Binding KeyUpCommand}" Event="KeyUp" />
        <cmn:AttachedCommandBinding Command="{Binding CloseCommand}" KeyGesture="ESC" />
    </cmn:AttachedCommandBehaviour.Bindings>

    <Path Fill="{Binding Configuration.OverlayColor, FallbackValue=Black}" Opacity="{Binding Configuration.OverlayColorOpacity, FallbackValue=0.6}" IsHitTestVisible="False">
        <Path.Data>
            <CombinedGeometry GeometryCombineMode="Exclude">
                <CombinedGeometry.Geometry1>
                    <RectangleGeometry Rect="{Binding Source={StaticResource RelativeScreenBounds}}" />
                </CombinedGeometry.Geometry1>
                <CombinedGeometry.Geometry2>
                    <RectangleGeometry Rect="{Binding CroppedArea}" />
                </CombinedGeometry.Geometry2>
            </CombinedGeometry>
        </Path.Data>
    </Path>
</Window>
